package com.teamwings.ctrls.controller;

import com.teamwings.common.vo.Result;
import com.teamwings.ctrls.entity.OatUserSms;
import com.teamwings.ctrls.service.OatUserSmsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 常用意见控制器
 * </p>
 *
 * @author jobob
 * @since 2021-05-05
 */
@RestController
@Api(tags = "常用意见管理")
@RequestMapping("/form")
public class UserSmsController {

    @Autowired
    private OatUserSmsService oatUserSmsService;

    /**
     * 修改常用意见
     *
     */
    @ApiOperation(value = "修改常用意见", notes = "")
    @PostMapping(value = "/sms/oaComment/update")
    public Result<?> update(@RequestBody OatUserSms oatUserSms) {
        boolean b = oatUserSmsService.updateById(oatUserSms);
        if (!b) {
            Result.error("修改失败");
        }
        return Result.OK("修改成功");
    }

    /**
     * 新增常用意见
     *
     */
    @ApiOperation(value = "新增常用意见", notes = "")
    @PostMapping(value = "/sms/oaComment/add")
    public Result<?> add(@RequestBody OatUserSms oatUserSms) {
        oatUserSms.setFActiveState(1);
        boolean b = oatUserSmsService.save(oatUserSms);
        if (!b) {
            Result.error("新增失败");
        }
        return Result.OK("新增成功");
    }
    /**
     * 删除常用意见
     *
     */
    @ApiOperation(value = "删除常用意见", notes = "")
    @PostMapping(value = "/sms/oaComment/del/{id}")
    public Result<?> del(@PathVariable String id) {
        boolean b = oatUserSmsService.removeById(id);
        if (!b) {
            Result.error("删除失败");
        }
        return Result.OK("删除成功");
    }


}
